package com.wang.bootbuilder.service;

import com.wang.bootbuilder.entity.dto.ExeclDictDto;
import com.wang.bootbuilder.entity.pojo.Category;
import com.wang.bootbuilder.mapper.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;

/*
操作execl的service
 */
@Service
public class DictService {

      @Autowired
      CategoryMapper categoryMapper;

      public List<ExeclDictDto> listDictData() {
          List<Category> categoryList = categoryMapper.selectList(null);
          List<ExeclDictDto> execlDictDtoList = new ArrayList<>();
          categoryList.stream().forEach(item -> {
              ExeclDictDto execlDictDto = new ExeclDictDto(String.valueOf(item.getId()), String.valueOf(item.getParentId()), item.getCategoryName(), item.getCreateBy());
              execlDictDtoList.add(execlDictDto);
          });
          return execlDictDtoList;
      }

}
